package Requests;
import java.io.*;

import default_package.InputParser;

public abstract class HTTPRequest {

private final String command;
private final String path;
private final String HTTPVersion;
private final PrintWriter pw;
private final String host;

public HTTPRequest(String[] input, PrintWriter pw, String host) {
	this.command = input[0];
	this.HTTPVersion = input[input.length - 1];
	this.path = InputParser.getFilePath(input[1], host);
	this.pw = pw;
	this.host = host;
}

public String getCommandToServer() {
	String commandLine = (this.command + " " + this.path +
			" " + this.HTTPVersion + "\r\n");
	return commandLine;
}

public String getTextBlock() {
	String textBlock = "";
	String temp = "";
	while (!(temp = InputParser.readLine()).equals("")) {
		textBlock = textBlock.concat(temp + "\r\n");
		}
	return textBlock;
}

public PrintWriter getPrintWriter() {
	return pw;
}

public String getCommand() {
	return command;
}

public abstract void execute();
}
